package com.tzy.note.base.copy;

import org.junit.jupiter.api.Test;

/**
 * @author tangzanyong
 * @description @TODO
 **/
public class CopyConstructorTest {
    @Test
    public void testCopy(){
        Age a=new Age(20);
        Person p1=new Person(a,"摇头耶稣");
        Person p2=new Person(p1);
        System.out.println("p1是:"+p1);
        System.out.println("p2是:"+p2);
        //修改p1的各属性值，观察p2的各属性值是否跟随变化
        p1.setName("小傻瓜");
        a.setAge(99);
        System.out.println("修改后的p1是:"+p1);
        System.out.println("修改后的p2是:"+p2);
    }
}
